package day0220;


public class Demo04 {

    public static void main(String[] args) {
//        Sup instance = new Sub();

        Sup instance = new Sub();

        /*
            父类类型变量引用子类对象：
                调用实例方法要看对象(new)是谁就调用谁的, 看等号右边
                调用静态方法要看变量的类型， 看等号左边
         */
        instance.instanceMethod();
//        instance.staticMethod();


    }
}



class Sup {

    public void instanceMethod() {
        System.out.println("Sup::instanceMethod");
    }

    public static void staticMethod() {
        System.out.println("Sup::staticMethod");
    }
}

class Sub extends Sup{

    @Override
    public void instanceMethod(){
        System.out.println("Sub::instanceMethod");
    }

    public static void staticMethod(){
        System.out.println("Sub::staticMethod");
    }
}
